Skip to content

feat(Android, FormSheet v5): Setup TouchHandler on Dialog window#4204

Merged
t0maboro merged 1 commit into
mainfrom
@t0maboro/formsheet-android-touch-handler
Jun 26, 2026
Merged

feat(Android, FormSheet v5): Setup TouchHandler on Dialog window#4204
t0maboro merged 1 commit into
mainfrom
@t0maboro/formsheet-android-touch-handler

Conversation

@t0maboro

@t0maboro t0maboro commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Description

This PR implements the touch and pointer event handling for the FormSheet by making the ContentView to act as a separate React RootView.

When rendering React Native components inside a native Dialog, the views are rendered in a completely separate window. This breaks touch event dispatching because React Native's main ReactRootView is completely unaware of this detached window.

To solve this, we make FormSheetContentView implement the RootView interface and instantiate its own JSTouchDispatcher and JSPointerDispatcher. By overriding the standard Android touch and hover methods and feeding the MotionEvents directly into these local dispatchers, we successfully forward user interactions from the dialog's window into the RN event system.

Because FormSheetContentView establishes itself as a new, independent RootView boundary, the MotionEvent coordinates supplied by the Android framework are naturally scoped to the bounds of the dialog's window, resulting in the proper coordinate mapping for the React children without any shadow tree contentOriginOffset corrections.

Closes: https://github.com/software-mansion/react-native-screens-labs/issues/1548

Changes

  • FormSheetContentView now acts as a RootView.
  • Copied JSTouchDispatcher from RN core modal implementation to handle standard MotionEvents
  • Copied JSPointerDispatcher from RN core modal implementation to handle pointer events and hover states

Before & after - visual documentation

formsheet-pressables-android.mov

Test plan

Base test for formsheets, verify that pressables are working properly.

Checklist

  • Included code example that can be used to test this change.
  • For visual changes, included screenshots / GIFs / recordings documenting the change.
  • For API changes, updated relevant public types.
  • Ensured that CI passes

@t0maboro t0maboro marked this pull request as ready for review June 23, 2026 15:05
@t0maboro t0maboro changed the base branch from main to @t0maboro/android-formsheet-v5 June 23, 2026 15:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes touch/pointer event dispatch for the Android FormSheet (rendered inside a native Dialog) by turning the dialog’s content container into its own React RootView, with local JSTouchDispatcher / JSPointerDispatcher instances to route MotionEvents into React Native correctly.

Changes:

  • Make FormSheetContentView implement RootView and forward touch/hover/gesture events to JSTouchDispatcher and JSPointerDispatcher.
  • Make FormSheetHost implement ReactPointerEventsView with pointerEvents = NONE so the “empty” host in the main window doesn’t block hit-testing behind it.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
android/src/main/java/com/swmansion/rnscreens/gamma/modals/formsheet/FormSheetHost.kt Marks the host view as non-hit-testable in the main window via pointerEvents = NONE.
android/src/main/java/com/swmansion/rnscreens/gamma/modals/formsheet/FormSheetContentView.kt Adds RootView-style touch/pointer dispatching so dialog-window interactions reach the RN event system.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@kmichalikk kmichalikk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runtime seems ok from quick glance, no further comments from me, but please look at what copilot added

@kligarski kligarski left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seem to be some problems with fast refresh and dynamically adding/removing views.

Screen.Recording.2026-06-24.at.14.57.34.mov

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like this class will be really closely tied to react so my comment from previous PR might be difficult to implement but maybe we can in the future pass this view (part of react impl) to container constructor (native impl) and everything will be nicely separated.

@t0maboro

Copy link
Copy Markdown
Contributor Author

There seem to be some problems with fast refresh and dynamically adding/removing views.

Screen.Recording.2026-06-24.at.14.57.34.mov

I see, will fix that in a followup: https://github.com/software-mansion/react-native-screens-labs/issues/1580 , added to current iteration

Base automatically changed from @t0maboro/android-formsheet-v5 to main June 26, 2026 13:06
@t0maboro t0maboro force-pushed the @t0maboro/formsheet-android-touch-handler branch from 645b17c to 937b641 Compare June 26, 2026 13:12
@t0maboro t0maboro merged commit b09beff into main Jun 26, 2026
5 of 6 checks passed
@t0maboro t0maboro deleted the @t0maboro/formsheet-android-touch-handler branch June 26, 2026 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants